import common.ListNode;

public class getIntersectionNode {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        //经典题目之一，双指针
        ListNode A = headA;
        ListNode B = headB;
        while (headA != headB) {
            headA = (headA == null) ? B : headA.next;
            headB = (headB == null) ? A : headB.next;
        }
        return headA;
    }
}
